#pragma once

#include <OISEvents.h> 
#include <OISInputManager.h> 
#include <OISKeyboard.h> 
#include <OISMouse.h>

#include <OgreFrameListener.h>
#include <OgreWindowEventUtilities.h>

#include "Common.h"
//#include <SDL.h>

class Input : public Ogre::WindowEventListener, public Ogre::FrameListener
{
	public:
		Input(void);
		~Input(void);

		void init(std::string hWnd, Ogre::RenderWindow* window, Ogre::Root *root);
		void destroy(bool callUnlisten = true);

		void update();

		bool isKeyDown(OIS::KeyCode key);

	private:
		OIS::InputManager* m_inputManager; 
		Ogre::RenderWindow* m_window;
		OIS::Mouse* m_mouse; 
		OIS::Keyboard* m_keyboard;
		Ogre::Root *m_root;

		void listen();
		void unlisten();

		inline void dropwindow(bool callUnlisten);

	protected:
		// Ogre::WindowEventListener 
		virtual void windowResized(Ogre::RenderWindow* rw); 
		virtual void windowClosed(Ogre::RenderWindow* rw);
		virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
};

